/*
=======================================================================

  BOTS Scientist Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_SCIENTIST_CREATE			1
#define BOTS_SCIENTIST_GENRESEARCH		2
#define BOTS_SCIENTIST_MAKEBOT			3
#define BOTS_SCIENTIST_KILLBOT			4
#define BOTS_SCIENTIST_UI_TEAMORDERS	5
#define BOTS_SCIENTIST_TRACKER			6

// Scientist
typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	create;
  menutext_s	genresearch;
  menutext_s	makebot;
  menutext_s	killbot;
  menutext_s	ui_teamorders;
  menutext_s	tracker;
  menutext_s	cancel;
} scientistCommands_t;

static scientistCommands_t		s_scientist;

/*
=================
BOTS_ScientistCommandsMenu_Event
callback routine
=================
*/
void BOTS_ScientistCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_SCIENTIST_CREATE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "create\n" );
		break;
	case BOTS_SCIENTIST_GENRESEARCH:
		trap_Cmd_ExecuteText( EXEC_APPEND, "genresearch\n" );
		break;
	case BOTS_SCIENTIST_MAKEBOT:
		trap_Cmd_ExecuteText( EXEC_APPEND, "makebot\n" );
		break;
	case BOTS_SCIENTIST_KILLBOT:
		trap_Cmd_ExecuteText( EXEC_APPEND, "killbot\n" );
		break;
	case BOTS_SCIENTIST_UI_TEAMORDERS:
		trap_Cmd_ExecuteText( EXEC_APPEND, "ui_teamorders\n" );
		break;
	case BOTS_SCIENTIST_TRACKER:
		trap_Cmd_ExecuteText( EXEC_APPEND, "tracker\n" );
		break;

	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_ScientistCommandsMenu_Init
=================
*/
void BOTS_ScientistCommandsMenu_Init() 
{
	int y;

	memset( &s_scientist, 0 ,sizeof(scientistCommands_t) );
	s_scientist.menu.wrapAround = qtrue;
	s_scientist.menu.fullscreen = qfalse;

	y = 96;
	s_scientist.title.generic.type	= MTYPE_PTEXT;
	s_scientist.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_scientist.title.generic.x		= 320;
	s_scientist.title.generic.y		= y;
	s_scientist.title.string		= "SCIENTIST COMMANDS MENU";
	s_scientist.title.color			= color_bots_menu;
	s_scientist.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_scientist.create.generic.type		= MTYPE_PTEXT;
	s_scientist.create.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_scientist.create.generic.x		= 320;
	s_scientist.create.generic.y		= y;
	s_scientist.create.generic.id		= BOTS_SCIENTIST_CREATE;
	s_scientist.create.generic.callback	= BOTS_ScientistCommandsMenu_Event; 
	s_scientist.create.string			= "CREATE ITEMS - create";
	s_scientist.create.color			= color_bots_menu;
	s_scientist.create.style			= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 1) {
		s_scientist.create.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_scientist.genresearch.generic.type		= MTYPE_PTEXT;
	s_scientist.genresearch.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_scientist.genresearch.generic.x			= 320;
	s_scientist.genresearch.generic.y			= y;
	s_scientist.genresearch.generic.id			= BOTS_SCIENTIST_GENRESEARCH;
	s_scientist.genresearch.generic.callback	= BOTS_ScientistCommandsMenu_Event; 
	s_scientist.genresearch.string				= "GENERAL RESEARCH - genresearch";
	s_scientist.genresearch.color				= color_bots_menu;
	s_scientist.genresearch.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 1) {
		s_scientist.genresearch.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_scientist.makebot.generic.type		= MTYPE_PTEXT;
	s_scientist.makebot.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_scientist.makebot.generic.x			= 320;
	s_scientist.makebot.generic.y			= y;
	s_scientist.makebot.generic.id			= BOTS_SCIENTIST_MAKEBOT;
	s_scientist.makebot.generic.callback	= BOTS_ScientistCommandsMenu_Event; 
	s_scientist.makebot.string				= "CREATE BOT - makebot";
	s_scientist.makebot.color				= color_bots_menu;
	s_scientist.makebot.style				= UI_CENTER|UI_SMALLFONT;

	//if (BOTS_GetClassLevel() < 2) {
		s_scientist.makebot.generic.flags |= QMF_GRAYED;
	//}

	y += BOTS_VERTICAL_SPACING;
	s_scientist.killbot.generic.type		= MTYPE_PTEXT;
	s_scientist.killbot.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_scientist.killbot.generic.x			= 320;
	s_scientist.killbot.generic.y			= y;
	s_scientist.killbot.generic.id			= BOTS_SCIENTIST_KILLBOT;
	s_scientist.killbot.generic.callback	= BOTS_ScientistCommandsMenu_Event; 
	s_scientist.killbot.string				= "KILL BOT - killbot";
	s_scientist.killbot.color				= color_bots_menu;
	s_scientist.killbot.style				= UI_CENTER|UI_SMALLFONT;

	//if (BOTS_GetClassLevel() < 2) {
		s_scientist.killbot.generic.flags |= QMF_GRAYED;
	//}

	y += BOTS_VERTICAL_SPACING;
	s_scientist.ui_teamorders.generic.type		= MTYPE_PTEXT;
	s_scientist.ui_teamorders.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_scientist.ui_teamorders.generic.x			= 320;
	s_scientist.ui_teamorders.generic.y			= y;
	s_scientist.ui_teamorders.generic.id		= BOTS_SCIENTIST_UI_TEAMORDERS;
	s_scientist.ui_teamorders.generic.callback	= BOTS_ScientistCommandsMenu_Event; 
	s_scientist.ui_teamorders.string			= "BOT COMMANDS - ui_teamorders";
	s_scientist.ui_teamorders.color				= color_bots_menu;
	s_scientist.ui_teamorders.style				= UI_CENTER|UI_SMALLFONT;

	//if (BOTS_GetClassLevel() < 2) {
		s_scientist.ui_teamorders.generic.flags |= QMF_GRAYED;
	//}

	y += BOTS_VERTICAL_SPACING;
	s_scientist.tracker.generic.type		= MTYPE_PTEXT;
	s_scientist.tracker.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_scientist.tracker.generic.x			= 320;
	s_scientist.tracker.generic.y			= y;
	s_scientist.tracker.generic.id			= BOTS_SCIENTIST_TRACKER;
	s_scientist.tracker.generic.callback	= BOTS_ScientistCommandsMenu_Event; 
	s_scientist.tracker.string				= "USE TRACKER - tracker";
	s_scientist.tracker.color				= color_bots_menu;
	s_scientist.tracker.style				= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_scientist.cancel.generic.type		= MTYPE_PTEXT;
	s_scientist.cancel.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_scientist.cancel.generic.x		= 320;
	s_scientist.cancel.generic.y		= y;
	s_scientist.cancel.generic.id		= BOTS_CANCEL;
	s_scientist.cancel.generic.callback	= BOTS_ScientistCommandsMenu_Event; 
	s_scientist.cancel.string			= "CANCEL";
	s_scientist.cancel.color			= color_bots_menu;
	s_scientist.cancel.style			= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_scientist.menu, &s_scientist.title );
	Menu_AddItem( &s_scientist.menu, &s_scientist.create );
	Menu_AddItem( &s_scientist.menu, &s_scientist.genresearch );
	Menu_AddItem( &s_scientist.menu, &s_scientist.makebot );
	Menu_AddItem( &s_scientist.menu, &s_scientist.killbot );
	Menu_AddItem( &s_scientist.menu, &s_scientist.ui_teamorders );
	Menu_AddItem( &s_scientist.menu, &s_scientist.tracker );
	Menu_AddItem( &s_scientist.menu, &s_scientist.cancel );
}

void BOTS_ScientistCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_ScientistCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_scientist.menu );
}
